﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace UniRx.Example
{
	public class SubjectExample : MonoBehaviour
	{
		Subject<string> mInputEvent = new Subject<string>();

		private IDisposable mInputEventSubscription = null;
		// Use this for initialization
		void Start()
		{
			mInputEventSubscription = mInputEvent.Subscribe(inputEvent =>
			{
				Debug.Log(inputEvent);
			});
		}

		private void OnDestroy()
		{
			mInputEventSubscription.Dispose();
			mInputEventSubscription = null;
		}

		// Update is called once per frame
		void Update()
		{

			if (Input.GetMouseButtonDown(0))
			{
				mInputEvent.OnNext("鼠标左键按下了");
			}

			if (Input.GetMouseButtonDown(1))
			{
				mInputEvent.OnNext("鼠标右键按下了");
			}
		}
	}
}